package p270jp.pxv.android.advertisement.presentation.viewholder;

import android.view.View;
import android.view.ViewGroup;
import androidx.lifecycle.AbstractC0721k;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import p181ge.AdViewHolder;
import p216hn.DefaultConstructorMarker;
import p270jp.pxv.android.R;
import p270jp.pxv.android.advertisement.presentation.view.NovelNativeAdSwitchView;
import p270jp.pxv.android.legacy.model.GoogleNg;
import p270jp.pxv.android.viewholder.BaseViewHolder;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p451qm.NeedsNovelItemDecoration;

/* compiled from: NovelAdItemViewHolder.kt */
/* renamed from: jp.pxv.android.advertisement.presentation.viewholder.NovelAdItemViewHolder */
/* loaded from: classes2.dex */
public final class NovelAdItemViewHolder extends BaseViewHolder implements LifecycleObserver, AdViewHolder, NeedsNovelItemDecoration {
    private final NovelNativeAdSwitchView adContainer;
    private GoogleNg googleNg = GoogleNg.WHITE;
    private boolean shouldRunningRotation;
    public static final Companion Companion = new Companion(null);
    public static final int $stable = 8;

    /* compiled from: NovelAdItemViewHolder.kt */
    /* renamed from: jp.pxv.android.advertisement.presentation.viewholder.NovelAdItemViewHolder$Companion */
    /* loaded from: classes2.dex */
    public static final class Companion {
        private Companion() {
        }

        public /* synthetic */ Companion(DefaultConstructorMarker eVar) {
            this();
        }

        public final int getLayoutRes() {
            return R.layout.view_novel_ad_solid_item;
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public NovelAdItemViewHolder(View view) {
        super(view);
        MutabilityOwnership.m3745m(view, "itemView");
        View findViewById = view.findViewById(R.id.ad_container);
        MutabilityOwnership.m3746l(findViewById, "itemView.findViewById(R.id.ad_container)");
        this.adContainer = (NovelNativeAdSwitchView) findViewById;
    }

    public static final int getLayoutRes() {
        return Companion.getLayoutRes();
    }

    private final void pauseRotation() {
        Timber.f23100a.mo3528a("pause", new Object[0]);
        this.adContainer.m4653d();
    }

    private final void startRotation() {
        Timber.f23100a.mo3528a("start", new Object[0]);
        this.adContainer.setGoogleNg(getGoogleNg());
        this.adContainer.m4651f();
    }

    public GoogleNg getGoogleNg() {
        return this.googleNg;
    }

    @Override // p181ge.AdViewHolder
    public void handleOnAttached() {
        this.shouldRunningRotation = true;
        startRotation();
    }

    @Override // p181ge.AdViewHolder
    public void handleOnDetached() {
        this.shouldRunningRotation = false;
        pauseRotation();
    }

    @OnLifecycleEvent(AbstractC0721k.EnumC0723b.ON_PAUSE)
    public final void handleOnPause() {
        pauseRotation();
    }

    @OnLifecycleEvent(AbstractC0721k.EnumC0723b.ON_RESUME)
    public final void handleOnResume() {
        if (this.shouldRunningRotation) {
            startRotation();
        }
    }

    @Override // p270jp.pxv.android.viewholder.BaseViewHolder
    public void onCreateView(ViewGroup viewGroup) {
        MutabilityOwnership.m3745m(viewGroup, "parent");
        super.onCreateView(viewGroup);
        this.adContainer.m4650g();
    }

    @OnLifecycleEvent(AbstractC0721k.EnumC0723b.ON_DESTROY)
    public final void releaseAd() {
        this.adContainer.m4652e();
    }

    @Override // p181ge.AdViewHolder
    public void setGoogleNg(GoogleNg googleNg) {
        MutabilityOwnership.m3745m(googleNg, "<set-?>");
        this.googleNg = googleNg;
    }
}
